package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build.VERSION;
import android.text.TextUtils;

public final class doi {
    private static boolean ˊ;
    private static String ˋ = "";
    private static String ˎ = "";
    private static int ॱ = 1;

    public static int ˎ(Context context) {
        ˊ(context);
        return ॱ;
    }

    public static String ˋ(Context context) {
        ˊ(context);
        return ˎ;
    }

    public static String ˏ(Context context) {
        ˊ(context);
        return ˋ;
    }

    private static synchronized void ˊ(Context context) {
        synchronized (doi.class) {
            if (!ˊ) {
                try {
                    PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                    ॱ = packageInfo.versionCode;
                    ˎ = packageInfo.versionName;
                    ˋ = ˏ(ˎ);
                    ˊ = true;
                } catch (NameNotFoundException e) {
                    Logger.e("TelphoneInformationManager", "can not find PackageInfo");
                }
            }
        }
    }

    private static String ˏ(String str) {
        if (TextUtils.isEmpty(str)) {
            return "";
        }
        int i = 0;
        int i2 = 0;
        while (i < str.length() && i2 < 3) {
            if (str.charAt(i) == '.') {
                i2++;
            }
            i++;
        }
        if (3 == i2) {
            return str.substring(0, i - 1);
        }
        return str;
    }

    public static String ॱ() {
        if (TextUtils.isEmpty(dok.ˊ())) {
            return ˊ(dok.ᐝ(), dok.ʼ(), dok.ॱॱ());
        }
        return dok.ˊ();
    }

    public static String ˊ(String str, String str2, String str3) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str3)) {
            return str;
        }
        if (TextUtils.isEmpty(str2)) {
            return str + "_" + str3;
        }
        return str + "_" + str2 + "_" + str3;
    }

    public static String ˊ() {
        return VERSION.RELEASE.trim();
    }
}
